package com.parktech.sun.domain.model.sms;

import com.parktech.sun.domain.model.Constants;
import com.parktech.sun.domain.model.addressbook.ContactMember;
import com.parktech.sun.domain.model.sunhz.Enterprise;
import com.parktech.sun.domain.model.system.User;
import org.hibernate.annotations.*;
import org.springframework.orm.hibernate3.support.ClobStringType;

import javax.persistence.*;
import javax.persistence.Entity;
import java.io.Serializable;
import java.util.Date;

/**
 * User: Think
 * Date: 2010-12-20
 * Time: 1:56:01
 */
@Entity
@TypeDefs(@TypeDef(name="clob",typeClass=ClobStringType.class))
public class Sms implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(length = 200, nullable = false)
    private String topic;

    @Lob
    @Type(type="clob")
    private String content;

    @Any(metaColumn = @Column(name = "to_acceptor_type"))
    @AnyMetaDef(idType = "long", metaType = "string",
            metaValues = {
             @MetaValue(targetEntity = ContactMember.class, value = "contactMember"),
             @MetaValue(targetEntity = Enterprise.class, value = "enterprise")
       })
    @JoinColumn(name="to_acceptor_id")
    private Object toAcceptor;

    private String acceptorSms;

    @Column(nullable = false,length = 26)
    private String status = Constants.ACTION_STATUS_SCHEDULED;

    @Column(name = "is_save_history")
    private boolean isSaveHistory = true;

    @Column(name = "is_schedule_send")
    private boolean isScheduleSend = false;

    @Column(name = "schedule_send_datetime")
    private Date scheduleSendDatetime = new Date();

    @Column(nullable = false)
    private Date createDatetime = new Date();

    @Column(nullable = false)
    private Date updateDatetime = new Date();

    @ManyToOne
    @JoinColumn(name = "creator_id")
    private User creator;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public boolean isSaveHistory() {
        return isSaveHistory;
    }

    public void setSaveHistory(boolean saveHistory) {
        isSaveHistory = saveHistory;
    }

    public boolean isScheduleSend() {
        return isScheduleSend;
    }

    public void setScheduleSend(boolean scheduleSend) {
        isScheduleSend = scheduleSend;
    }

    public Date getScheduleSendDatetime() {
        return scheduleSendDatetime;
    }

    public void setScheduleSendDatetime(Date scheduleSendDatetime) {
        this.scheduleSendDatetime = scheduleSendDatetime;
    }

    public Object getToAcceptor() {
        return toAcceptor;
    }

    public void setToAcceptor(Object toAcceptor) {
        this.toAcceptor = toAcceptor;
    }

    public String getAcceptorSms() {
        return acceptorSms;
    }

    public void setAcceptorSms(String acceptorSms) {
        this.acceptorSms = acceptorSms;
    }

 /*   public Object getAcceptor() {
        return acceptor;
    }

    public void setAcceptor(Object acceptor) {
        this.acceptor = acceptor;
    }
*/
    public Date getCreateDatetime() {
        return createDatetime;
    }

    public void setCreateDatetime(Date createDatetime) {
        this.createDatetime = createDatetime;
    }

    public Date getUpdateDatetime() {
        return updateDatetime;
    }

    public void setUpdateDatetime(Date updateDatetime) {
        this.updateDatetime = updateDatetime;
    }

    public User getCreator() {
        return creator;
    }

    public void setCreator(User creator) {
        this.creator = creator;
    }
}
